package com.example.travelservlet.love.service;

import com.example.travelservlet.entity.Focus;
import com.example.travelservlet.entity.Label;
import com.example.travelservlet.entity.User;
import com.example.travelservlet.love.dao.LoveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yxj
 * @date 2023/6/13 8:20
 */
@Service
public class LoveService {
    @Autowired
    private LoveMapper loveMapper;

    public Label findLabelById(String labelId) {
        Label label = loveMapper.findLabelById(labelId);
        return label;
    }

    public List<String> findLabelId(String userId) {
        return loveMapper.findLovesById(userId);
    }

    public List<Label> findLoveLabelsByUserId(String userId) {
        List<String> lovesById = loveMapper.findLovesById(userId);
        List<Label> labelList = new ArrayList<>();
        for (int i = 0; i < lovesById.size(); i++) {
            Label label = loveMapper.findLabelById(lovesById.get(i));
            labelList.add(label);
        }
        return labelList;
    }

    public List<Label> findAllLabel() {
        return loveMapper.findAllLabel();
    }

    public Integer addUserLabel(String userId, String labelId) {
        Integer integer = loveMapper.addLabel(userId, labelId);
        return integer;
    }

    public Integer deleteLabels(String userId, String labelId) {
        Integer integer = loveMapper.delectLabel(userId, labelId);
        return integer;
    }
}
